home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / MPW Extras ƒ / MPW / Scripts / NewNew < prev    next >
Encoding:
Text File  |  1991-08-29  |  2.4 KB  |  53 lines  |  [TEXT/MPS ]

  1. # NewNew - replacement "New" script supporting file backup and remember
  2.  
  3. Set ScriptName "{0}"                                                            # save the script's name
  4. Set NFile "{#}"                                                                    # get number of command line arguments
  5. If ({NFile} == 0)
  6.     # no command line arguments - New will use GetFileName to prompt for a new document name
  7.     Set CmdStr "`Begin; GetFileName -b New -m "Open document" -p; Set NewStatus {Status}; End ≥ Dev:Null`"
  8.     If ({NewStatus} == 0)
  9.         Open -n {CmdStr} ∑∑ Dev:Null                                            # try to create the new file
  10.         Set NewStatus {Status}
  11.         If ({NewStatus} == 0)
  12.             # the New was successful - delete any old "Remember" backup files
  13.             Set LeafName "`ParseFileName -l "{Active}"`"                        # get the file's leafname
  14.             For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
  15.                 Delete "{i}"
  16.             End  # For i
  17.             DeRez -only "'MPSR' (1006)" "{Worksheet}" > DeRez.tmp                # get the standard print options from the Worksheet
  18.             Rez -a -o "{Active}" DeRez.tmp                                        # transfer to the target file
  19.             Delete DeRez.tmp                                                    # delete the temporary file
  20.             Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep            # create the backup file
  21.         Else
  22.             Alert "{ScriptName} - unable to open the new file {CmdStr}."
  23.         End  # If {NewStatus}
  24.     Else
  25.         If ({NewStatus} != 4)
  26.             Alert "{ScriptName}:∂nUnable to continue due to GetFileName error #{NewStatus}."
  27.         End  # If {NewStatus}
  28.     End  # If {NewStatus}
  29. Else
  30.     Loop
  31.         Break If ({NFile} <= 0)                                                    # exit if all arguments have been processed
  32.         New "{1}" ∑∑ Dev:Null
  33.         Set NewStatus {Status}
  34.         If ({NewStatus} == 0)
  35.             # the New was successful - delete any old "Remember" backup files
  36.             Set LeafName "`ParseFileName -l "{1}"`"                                # get the file's leafname
  37.             For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
  38.                 Delete "{i}"
  39.             End  # For i
  40.             DeRez -only "'MPSR' (1006)" "{Worksheet}" > DeRez.tmp                # get the standard print options from the Worksheet
  41.             Rez -a -o "{1}" DeRez.tmp                                            # transfer to the target file
  42.             Delete DeRez.tmp                                                    # delete the temporary file
  43.             Duplicate -y "{1}" "{Backup}" ∑∑ "{Worksheet}" || Beep                # create the backup file
  44.         Else
  45.             # an error occured that was not a user cancellation
  46.             Alert "{ScriptName}:∂nUnable to open new file {1}."
  47.         End  # If {NewStatus}
  48.     Shift
  49.     Evaluate NFile -= 1                                                            # update the argument counter
  50.     End  # Loop
  51. End  # If {NFile}
  52.  
  53. # end of NewNew